package com.sumainfor.wx.tenant.controller.provider;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.wx.tenant.service.TctenTenantIdentitService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author Eddy·Chen
 * @Email 835033913@qq.com
 * @Create 2019-05-06 14:47
 * 财务部服务提供者
 */
@RestController
@RequestMapping("/key/provider/cfo")
public class CfoProviderController {

    @Autowired
    private TctenTenantIdentitService identitService;


    /**
     * 模糊查询租客数据信息
     *
     * @param search
     * @return
     */
    @PostMapping("/getUserInfoListByLikeSelect")
    public List<Map<String, Object>> getUserInfoListByLikeSelect(String search) {
        if (StringUtils.isBlank(search)) {
            return null;
        }
        return identitService.getUserInfoListByLikeSelect(search);
    }

    /**
     * 根据传入的租客编号集合 查询租客信息数据
     *
     * @param ids
     * @return
     */
    @PostMapping("/selectTenantInfoByIdList")
    public List<Map<String, Object>> selectTenantInfoByIdList(@RequestBody List<String> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return null;
        }
        return identitService.selectTenantInfoByIdList(ids);
    }

    /**
     * 查询租客信息通过租客手机号码
     *
     * @param phone
     * @return
     */
    @PostMapping("/getTenantByPhone")
    public JsonResult getTenantByPhone(String phone) {
        return JsonResult.success(identitService.getTenantByPhone(phone));
    }

}
